package BoostedTest::Form::Testplans;
use strict;
use warnings;
use base qw[ BoostedTest::Form ];

sub init_with_testplan {
   my $self  = shift;
   my $testplan = shift;
   if (!$testplan or !$testplan->isa('BoostedTest::RDBO::Testplan')) {
#       die "need BoostedTest::RDBO::Testplan object";
	return;
   }
   return $self->init_with_object($testplan);
}

sub testplan_from_form {
   my $self = shift;
   my $testplan = shift;
   if (!$testplan or !$testplan->isa('BoostedTest::RDBO::Testplan')) {
 #      die "need BoostedTest::RDBO::Testplan object";
	return;
   }
   $self->object_from_form($testplan);
   return $testplan;
}

1;

package BoostedTest::Form::Testplans::Edit;
use base qw[ BoostedTest::Form::Testplans ];

sub build_form {
   my $self = shift;
   $self->method("POST");
   $self->add_fields(
       title => {
           type         => 'hidden',
         },
       users_id => {
           type         => 'popup menu',
           required     => 1,
           label        => 'User name',
           options      => { 1 => 'Dmitry', 2 => 'Tripsy', 3 => 'Poopsy' },
         },

       language_id => {
           type         => 'popup menu',
           required     => 1,
           label        => 'Language',
           options      => { 1 => 'enx', 2 => 'enu', 3 => 'eng' },
         },
       name => {
           type         => 'text',
           required     => 1,
           label        => 'Name',
	   maxlength    => 255,
         },
       description => {
           type         => 'textarea',
           required     => 0,
           label        => 'Desc',
	   rows         => 5,
           cols         => 50,
         },
       content => {
           type         => 'textarea',
           required     => 0,
           label        => 'Desc',
	   rows         => 5,
           cols         => 50,
         },
       
       submit => {
           type         => 'submit',
       }
   );
}

sub validate
{
    my($self) = shift;

    # Base class will validate individual fields in isolation,
    # confirming that all required fields are filled in, and that
    # the email address and phone number are formatted correctly.
    my $ok = $self->SUPER::validate;
    return $ok  if !$ok;
    
    return 1;
}

1;